/*
 * @Date: 2021-08-13 16:49:37
 * @LastEditTime: 2021-08-31 11:37:56
 */
import productsAddDialog from '../components/productsAddDialog.vue'
import thund from '@/components/base/thund'
import dicValues from '@/components/dicTransform/index'
const productAdd = {
    components: {
        productsAddDialog,
        thund,
        dicValues
    },
    data() {
        return {
            loading: false,
            tableData: [], // table 表格数据
            selectTableList: [], // 选择 表格数据
            DICTIONARIES: {
                splitOrder: [{
                    code: 1,
                    name: '普通商品'
                },
                {
                    code: 2,
                    name: '多箱包装'
                }
                ]
            }
        }
    },
    methods: {
        /**
         * table选择处理函数
         * */
        tableSelectHandler(e) {
            const vm = this
            vm.selectTableList = e
        },
        // 批量删除
        delProducts() {
            const vm = this
            vm.formFieldsData.products = vm.formFieldsData.products.filter(
                (ele) =>
                    vm.selectTableList.findIndex((e) => e.goods_id === ele.goods_id) ===
                    -1
            )
        },
        // 删除
        delProduct(id) {
            const vm = this
            const index = vm.formFieldsData.products.findIndex(
                (e) => e.goods_id === id
            )
            this.formFieldsData.products.splice(index, 1)
        }
    }
}
export default productAdd